package com.zcgk.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/****************************************************
 *
 * swagger config
 *
 *
 * @author Francis
 * @date 2020/1/19 20:05
 * @version 1.0
 **************************************************/
@Configuration
@EnableSwagger2
public class Swagger2Config {

    /**
     * 创建api应用
     *
     * @return springfox.documentation.spring.web.plugins.Docket
     */
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zcgk.modules"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * 创建api基本信息
     *
     * @return springfox.documentation.service.ApiInfo
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("api文档")
                .description("集成了所有的公共方法.\n\n-- Create By Francis")
                .termsOfServiceUrl("http://localhost:8090")
                .version("1.0")
                .contact(new Contact("Francis", "http://www.zcgk.com", "shunzhongx@gmail.com"))
                .build();
    }
}